package com.ruoyi.course.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.course.domain.time_slot;
import com.ruoyi.course.service.Itime_slotService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 时间段管理Controller
 * 
 * @author chenxl
 * @date 2025-06-29
 */
@RestController
@RequestMapping("/course/time_slot")
public class time_slotController extends BaseController
{
    @Autowired
    private Itime_slotService time_slotService;

    /**
     * 查询时间段管理列表
     */
   // @PreAuthorize("@ss.hasPermi('course:time_slot:list')")
    @GetMapping("/list")
    public TableDataInfo list(time_slot time_slot)
    {
        startPage();
        List<time_slot> list = time_slotService.selecttime_slotList(time_slot);
        return getDataTable(list);
    }

    /**
     * 导出时间段管理列表
     */
    @PreAuthorize("@ss.hasPermi('course:time_slot:export')")
    @Log(title = "时间段管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, time_slot time_slot)
    {
        List<time_slot> list = time_slotService.selecttime_slotList(time_slot);
        ExcelUtil<time_slot> util = new ExcelUtil<time_slot>(time_slot.class);
        util.exportExcel(response, list, "时间段管理数据");
    }

    /**
     * 获取时间段管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('course:time_slot:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(time_slotService.selecttime_slotById(id));
    }

    /**
     * 新增时间段管理
     */
    @PreAuthorize("@ss.hasPermi('course:time_slot:add')")
    @Log(title = "时间段管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody time_slot time_slot)
    {
        return toAjax(time_slotService.inserttime_slot(time_slot));
    }

    /**
     * 修改时间段管理
     */
    @PreAuthorize("@ss.hasPermi('course:time_slot:edit')")
    @Log(title = "时间段管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody time_slot time_slot)
    {
        return toAjax(time_slotService.updatetime_slot(time_slot));
    }

    /**
     * 删除时间段管理
     */
    @PreAuthorize("@ss.hasPermi('course:time_slot:remove')")
    @Log(title = "时间段管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(time_slotService.deletetime_slotByIds(ids));
    }
}
